﻿using System.Collections.Generic;
using FollowMe.Model;
using FollowMe.Services.Response;

namespace FollowMe.Services.Mappers
{
    public static class FriendExtensionMethods
    {
        public static FriendView ConvertToFriendView(this Member friend)
        {
            return new FriendView
            {
                friendID = friend.MemberId,
                email = friend.Email,
                firstName = friend.FirstName,
                lastName = friend.LastName,
                middleInitial = friend.MiddleInitial,
                userName = friend.UserName
            };
        }

        public static FriendView initializeFriendView(this Friend friend)
        {
            return new FriendView
            {
                friendID = friend.FriendAddedID,
            };
        }

        public static IList<FriendView> initializeFriendViews(this IEnumerable<Friend> friends)
        {
            IList<FriendView> friendViews = new List<FriendView>();
            foreach (Friend friend in friends)
            {
                friendViews.Add(friend.initializeFriendView());
            }
            return friendViews;
        }

        public static IList<FriendView> ConvertToFriendViews(this IEnumerable<Member> friends)
        {
            IList<FriendView> friendViews = new List<FriendView>();
            foreach (Member friend in friends)
            {
                friendViews.Add(friend.ConvertToFriendView());
            }
            return friendViews;
        }
    }
}